export class BuildPrinter {
  #startStamp = 0;
  #loadEndStamp = 0;
  #compiledStamp = 0;
  #name = "";
  constructor(name: string = "") {
    this.#name = name;
  }
  start() {
    this.#startStamp = performance.now();
    console.log(`---${this.#name} Build Init---`);
  }

  loaded() {
    this.#loadEndStamp = performance.now();
    console.log(`---${this.#name} Build Start---`);
  }

  compiled() {
    this.#compiledStamp = performance.now();
    console.log(`---${this.#name} Compiled---`);
  }

  done() {
    console.log(`---${this.#name} Build End---`);
    console.log(
      `---Load    Cost ${this.#loadEndStamp - this.#startStamp} ms---`
    );
    console.log(
      `---Compile Cost ${this.#compiledStamp - this.#loadEndStamp} ms---`
    );
    const now = performance.now();
    console.log(`---Done    Cost ${now - this.#compiledStamp} ms---`);
    console.log(`---Total   Cost ${now - this.#startStamp} ms---`);
  }
}
